import instance from "../axiosConfig";

export function translate(q) {
    return new Promise((resolve, reject) => {
        instance({
            method: "get",
            url: "/api/public/util/translate",
            params: {
                q: q,
            },
        }).then((res) => {
            const { code, data } = res.data;
            if (code == 200) {
                if (data.hasOwnProperty("trans_result")) {
                    resolve(data.trans_result);
                } else {
                    reject("翻译失败");
                }
            } else {
                reject("调用服务失败");
            }
        });
    });
}
